/* ActorHMesh - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */
package com.maddox.il2.engine;
import com.maddox.rts.Time;

public abstract class ActorHMesh extends ActorMesh
{
    private HierMesh hmesh = null;
    private static Loc _L = new Loc();
    
    public HierMesh hierMesh() {
	return hmesh;
    }
    
    public Mesh mesh() {
	return hmesh == null ? (Mesh) super.mesh() : hmesh;
    }
    
    public float collisionR() {
	return mesh().collisionR();
    }
    
    public int[] hideSubTrees(String string) {
	return hmesh.hideSubTrees(string);
    }
    
    public void destroyChildFiltered(Class var_class) {
	Object[] objects = getOwnerAttached();
	for (int i = 0; i < objects.length; i++) {
	    if (objects[i] != null && var_class.isInstance(objects[i]))
		((Actor) objects[i]).destroy();
	}
    }
    
    public void getChunkLoc(Loc loc) {
	hmesh.getChunkLocObj(loc);
    }
    
    public void getChunkLocAbs(Loc loc) {
	hmesh.getChunkLocObj(loc);
	loc.add(pos.getAbs());
    }
    
    public void getChunkLocTimeAbs(Loc loc) {
	hmesh.getChunkLocObj(loc);
	pos.getTime(Time.current(), _L);
	loc.add(_L);
    }
    
    public float getChunkMass() {
	return hmesh.getChunkMass();
    }
    
    public void destroy() {
	if (!isDestroyed()) {
	    super.destroy();
	    if (hmesh != null) {
		hmesh.destroy();
		hmesh = null;
	    }
	}
    }
    
    protected ActorHMesh() {
	/* empty */
    }
    
    protected ActorHMesh(Loc loc) {
	super(loc);
    }
    
    protected ActorHMesh(ActorPos actorpos) {
	super(actorpos);
    }
    
    public void setMesh(String string) {
	boolean bool = mesh() != null && pos != null;
	if (string.endsWith(".sim")) {
	    hmesh = null;
	    super.setMesh(string);
	} else {
	    mesh = null;
	    hmesh = new HierMesh(string);
	}
	if (bool)
	    pos.actorChanged();
    }
    
    public void setMesh(Mesh mesh) {
	boolean bool = mesh() != null && pos != null;
	this.mesh = mesh;
	hmesh = null;
	if (bool)
	    pos.actorChanged();
    }
    
    protected void setMesh(HierMesh hiermesh) {
	boolean bool = mesh() != null && pos != null;
	hmesh = hiermesh;
	mesh = null;
	if (bool)
	    pos.actorChanged();
    }
    
    public ActorHMesh(String string) {
	try {
	    setMesh(string);
	} catch (RuntimeException runtimeexception) {
	    super.destroy();
	    throw runtimeexception;
	}
    }
    
    public ActorHMesh(String string, Loc loc) {
	super(loc);
	try {
	    setMesh(string);
	} catch (RuntimeException runtimeexception) {
	    super.destroy();
	    throw runtimeexception;
	}
    }
    
    public ActorHMesh(String string, ActorPos actorpos) {
	super(actorpos);
	try {
	    setMesh(string);
	} catch (RuntimeException runtimeexception) {
	    super.destroy();
	    throw runtimeexception;
	}
    }
    
    public ActorHMesh(HierMesh hiermesh, Loc loc) {
	super(loc);
	try {
	    setMesh(hiermesh);
	} catch (RuntimeException runtimeexception) {
	    super.destroy();
	    throw runtimeexception;
	}
    }
}
